/* GUI CONVERTED from rcsomte1.p (converter v1.76) Tue Apr 23 11:59:48 2002 */
/* rcsomte1.p - SALES ORDER HEADER CONSIGNMENT POP-UP FRAME                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/* $Revision: 1.7 $                        */

/* $Revision: 1.7 $   BY: Patrick Rowan   DATE: 04/04/02  ECO: *P00F* */

/*V8:ConvertMode=Maintenance                                                */
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*!
  ----------------------------------------------------------------------------
  DESCRIPTION: This program controls a frame containing consignment variables.

  Notes:
  1.  This program can be used by Maintenance screens, Inquiries, and Reports.
        The input parameter, in_update, indicates that this program should
        allow updates to the variables.
  2.  This program can be used by both Sales Order programs and Scheduled
        Order programs.  The input parameter, in_schedule, indicates that the
        calling program is a Customer Schedule program and will display the
        frame associated with customer schedules.

  ============================================================================
!*/
{mfdeclre.i}
{gplabel.i}
{socnvars.i}
{pxsevcon.i}
{socnctrl.i}
{gpcnmsg.i}
{socnso.i}

/* INPUT PARAMETERS */
define input-output parameter table for tt_so_mstr.
define input parameter in_update    like mfc_logical no-undo.
define input parameter in_schedule  like mfc_logical no-undo.

define buffer bCustConsignPopup for tt_so_mstr.


find first bCustConsignPopup.

assign
   bCustConsignPopup.in_update = in_update
   bCustConsignPopup.in_schedule = in_schedule.


/* FORM STATEMENT: FRAME so_consign */

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
bCustConsignPopup.so_consign_loc             colon 26
   bCustConsignPopup.so_intrans_loc             colon 26
   bCustConsignPopup.so_max_aging_days          colon 26
 SKIP(.4)  /*GUI*/
with frame so_consign width 80 side-labels attr-space
 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-so_consign-title AS CHARACTER.
 F-so_consign-title = (getFrameTitle("CONSIGNMENT_ORDER_DATA",70)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame so_consign = F-so_consign-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame so_consign =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame so_consign + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame so_consign =
  FRAME so_consign:HEIGHT-PIXELS - RECT-FRAME:Y in frame so_consign - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME so_consign = FRAME so_consign:WIDTH-CHARS - .5. /*GUI*/


/*Set frame labels */
setFrameLabels(frame so_consign:handle).

/* FORM STATEMENT: FRAME so_consign_sched */

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
bCustConsignPopup.so_consign_loc             colon 26
   bCustConsignPopup.so_auto_replenish          colon 60
   bCustConsignPopup.so_intrans_loc             colon 26
   bCustConsignPopup.so_max_aging_days          colon 26
 SKIP(.4)  /*GUI*/
with frame so_consign_sched width 80 side-labels attr-space
 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-so_consign_sched-title AS CHARACTER.
 F-so_consign_sched-title = (getFrameTitle("CONSIGNMENT_ORDER_DATA",70)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame so_consign_sched = F-so_consign_sched-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame so_consign_sched =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame so_consign_sched + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame so_consign_sched =
  FRAME so_consign_sched:HEIGHT-PIXELS - RECT-FRAME:Y in frame so_consign_sched - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME so_consign_sched = FRAME so_consign_sched:WIDTH-CHARS - .5. /*GUI*/


/*Set frame labels */
setFrameLabels(frame so_consign_sched:handle).

run readSalesOrderMasterRecord
    (buffer bCustConsignPopup,
     input {&NO_LOCK_FLAG},
     input {&WAIT_FLAG}).

/* DISPLAY CONSIGNMENT VALUES */
if bCustConsignPopup.in_schedule then
   display
      bCustConsignPopup.so_consign_loc
      bCustConsignPopup.so_intrans_loc
      bCustConsignPopup.so_max_aging_days
      bCustConsignPopup.so_auto_replenish
   with frame so_consign_sched.
else
   display
      bCustConsignPopup.so_consign_loc
      bCustConsignPopup.so_intrans_loc
      bCustConsignPopup.so_max_aging_days
   with frame so_consign.


/* UPDATE CONSIGNMENT VALUES, IF CALLED FROM MAINTENANCE PGM */
if bCustConsignPopup.in_update then do:

   repeatloop:
   do on error undo, retry on endkey undo, leave:
/*GUI*/ if global-beam-me-up then undo, leave.


      setloop:
      do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


         if bCustConsignPopup.in_schedule then
             set
                 bCustConsignPopup.so_consign_loc
                 bCustConsignPopup.so_intrans_loc
                 bCustConsignPopup.so_max_aging_days
                 bCustConsignPopup.so_auto_replenish
             with frame so_consign_sched.
         else
             set
                 bCustConsignPopup.so_consign_loc
                 bCustConsignPopup.so_intrans_loc
                 bCustConsignPopup.so_max_aging_days
             with frame so_consign.


         /* VALIDATE CONSIGNMENT LOCATION */
         if bCustConsignPopup.so_consign_loc = "" then do:

            /* BLANK NOT ALLOWED */
            run displayMessage
                (input "40",
                 input 3).

            if bCustConsignPopup.in_schedule then
               next-prompt bCustConsignPopup.so_consign_loc
               with frame so_consign_sched.
            else
               next-prompt bCustConsignPopup.so_consign_loc
               with frame so_consign.

            undo, retry setloop.
         end.
         else do:

            {gprun.i ""socnval1.p""
                 "(input bCustConsignPopup.so_consign_loc,
                   input bCustConsignPopup.so_site,
                   input bCustConsignPopup.in_schedule)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if return-value <> {&SUCCESS-RESULT} then do:
               if bCustConsignPopup.in_schedule then
                  next-prompt bCustConsignPopup.so_consign_loc
                  with frame so_consign_sched.
               else
                  next-prompt bCustConsignPopup.so_consign_loc
                  with frame so_consign.

                undo, retry setloop.
            end.
         end.  /* else do */


         /* VALIDATE IN-TRANSIT LOCATION */
         if bCustConsignPopup.so_intrans_loc <> "" then do:

            {gprun.i ""socnval1.p""
                 "(input bCustConsignPopup.so_intrans_loc,
                   input bCustConsignPopup.so_site,
                   input bCustConsignPopup.in_schedule)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            if return-value <> {&SUCCESS-RESULT} then do:
               if bCustConsignPopup.in_schedule then
                  next-prompt bCustConsignPopup.so_intrans_loc
                  with frame so_consign_sched.
               else
                  next-prompt bCustConsignPopup.so_intrans_loc
                  with frame so_consign.

               undo, retry setloop.
            end.
         end.  /* if intrans_loc <> "" */


         run updateSalesOrderMasterRecord
             (buffer bCustConsignPopup).


      end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* setloop */

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* repeat */

end.  /* if in_update */

if bCustConsignPopup.in_schedule then
   hide frame so_consign_sched.
else
   hide frame so_consign.
